
local userId = KEYS[1]

local amount = ARGV[1]

local ttl = ARGV[2]


local currentAmount = redis.call('GET', userId)


if currentAmount == false then 

	
	redis.call('SET', userId, amount)

	redis.call('expire', userId, ttl)
	
	return 0

else 
	
	redis.call('SET', userId, currentAmount + amount)

	redis.call('expire', userId, ttl)

	return 1

end